package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TOpenMoney;
import com.ruoyi.project.mahjong.service.ITOpenMoneyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 会员开桌中商品消费Controller
 *
 * @author ruoyi
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/mahjong/moneying")
public class TOpenMoneyController extends BaseController
{
    @Autowired
    private ITOpenMoneyService tOpenMoneyService;

    /**
     * 查询会员开桌中商品消费列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:moneying:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOpenMoney tOpenMoney)
    {
        startPage();
        List<TOpenMoney> list = tOpenMoneyService.selectTOpenMoneyList(tOpenMoney);
        return getDataTable(list);
    }

    /**
     * 导出会员开桌中商品消费列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:moneying:export')")
    @Log(title = "会员开桌中商品消费", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TOpenMoney tOpenMoney)
    {
        List<TOpenMoney> list = tOpenMoneyService.selectTOpenMoneyList(tOpenMoney);
        ExcelUtil<TOpenMoney> util = new ExcelUtil<TOpenMoney>(TOpenMoney.class);
        return util.exportExcel(list, "moneying");
    }

    /**
     * 获取会员开桌中商品消费详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:moneying:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tOpenMoneyService.selectTOpenMoneyById(id));
    }

    /**
     * 新增会员开桌中商品消费
     */
    @PreAuthorize("@ss.hasPermi('mahjong:moneying:add')")
    @Log(title = "会员开桌中商品消费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOpenMoney tOpenMoney)
    {
        return toAjax(tOpenMoneyService.insertTOpenMoney(tOpenMoney));
    }

    /**
     * 修改会员开桌中商品消费
     */
    @PreAuthorize("@ss.hasPermi('mahjong:moneying:edit')")
    @Log(title = "会员开桌中商品消费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOpenMoney tOpenMoney)
    {
        return toAjax(tOpenMoneyService.updateTOpenMoney(tOpenMoney));
    }

    /**
     * 删除会员开桌中商品消费
     */
/*    @PreAuthorize("@ss.hasPermi('mahjong:moneying:remove')")*/
    @Log(title = "会员开桌中商品消费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tOpenMoneyService.deleteTOpenMoneyByIds(ids));
    }
}
